package mornd.beannameurl;

import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping;

/**
 * @author: mornd
 * @dateTime: 2023/5/9 - 16:30
 * 将请求名称与bean的名称进行映射（要求 bean 名称以/开头，并且实现 Controller 接口）
 * 映射器：BeanNameUrlHandlerMapping
 * 处理器：Controller
 * 适配器：SimpleControllerHandlerAdapter
 */
public class App {
    public static void main(String[] args) {
        AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(WebConfig.class);
        BeanNameUrlHandlerMapping handlerMapping = context.getBean(BeanNameUrlHandlerMapping.class);

        handlerMapping.getHandlerMap().forEach((k,v) -> {
            System.out.println(k + "==>" + v);
        });

    }
}
